﻿using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Minecraft_Armor_Stand_Creater.Resource.Controls
{
    /// <summary>
    /// ResetButton.xaml 的交互逻辑
    /// </summary>
    public partial class ResetButton : UserControl
    {
        public ResetButton()
        {
            InitializeComponent();
            rectangle2.MouseLeftButtonDown += CheckRestEvent;
            rectangle2.MouseLeave += CancelRestEvent;
        }

        public bool _IsConfirmRest = false;

        bool confirmState = false;
        /// <summary> 点击确认是否通过 </summary>
        [Description("UserControl"), Category("User Control")]
        public bool IsConfirmRest
        {
            get { return _IsConfirmRest; }
            set { confirmState = _IsConfirmRest = value; }
        }

        public string _restContent;
        /// <summary> 确认提示显示的文本内容 </summary>
        [Description("UserControl"), Category("User Control")]
        public string RestContent
        {
            get { return _restContent; }
            set { label.Content = _restContent = value; }
        }

        bool checkState = false;

        void CheckRestEvent(object sender, MouseButtonEventArgs e)
        {
            if (checkState)
            {
                IsConfirmRest = confirmState = true;
                VisualStateManager.GoToState(this, "ConfirmRest", true);
            }
            else VisualStateManager.GoToState(this, "CheckRest", true);

            checkState = !checkState;
        }

        void CancelRestEvent(object sender, MouseEventArgs e)
        {
            checkState = false;
            VisualStateManager.GoToState(this, "Base", true);
        }
    }
}
